package com.wufeng.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wufeng.dto.R;
import com.wufeng.entity.QuestionOption;
import com.wufeng.service.QuestionOptionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;

@RestController
@RequestMapping("/questionoption")
public class QuestionOptionController {

    @Autowired
    private QuestionOptionService questionOptionService;

    /**
     * 根据问题id获取选项
     * @param questionId
     * @return
     */
    @GetMapping("/getQuestionOptionByQuestionId")
    public R getQuestionOptionByQuestionId(@RequestParam("questionId") Integer questionId) {
        List<QuestionOption> list = questionOptionService.list(new QueryWrapper<QuestionOption>().eq("questionId", questionId));
        HashMap<String, Object> map = new HashMap<>();
        map.put("list",list);
        return R.ok(map);
    }
}
